<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserfilesTable extends Migration
{
    /**
     * Run the migrations.
     * @return void
     */
    public function up()
    {
        Schema::create('user_folders', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('f_id')->default(0)->comment('父目录Id');
            $table->unsignedInteger('user_id')->default(0)->comment('用户Id');
            $table->unsignedInteger('sort')->default(0)->comment('序号');
            $table->string('name', 100)->default('')->comment('目录名称');
            $table->dateTime('created_at')->nullable()->comment('创建时间');
            $table->dateTime('updated_at')->nullable()->comment('更新时间');
        });
        Schema::create('user_files', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('folder_id')->default(0)->comment('目录Id');
            $table->unsignedInteger('user_id')->default(0)->comment('用户Id');
            $table->string('title', 100)->default('')->comment('标题');
            $table->string('file1', 100)->default('')->comment('文件');
            $table->string('orig_name', 100)->default('')->comment('原文件名');
            $table->string('file_type', 50)->default('')->comment('文件类型');
            $table->unsignedBigInteger('file_size')->default(0)->comment('文件大小');
            $table->string('file_ext', 10)->default('')->comment('扩展名');
            $table->dateTime('created_at')->nullable()->comment('创建时间');
            $table->dateTime('updated_at')->nullable()->comment('更新时间');
        });
    }

    /**
     * Reverse the migrations.
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_folders');
        Schema::dropIfExists('user_files');
    }
}
